﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CSP.Receipts.Business;
using Ninject;

namespace MySharpReceipts.Controllers
{
    public class MiscController : BaseController
    {
        public ActionResult ReceiptImage(int id)
        {
            var repository = Kernel.Get<IPictureRepository>();
            var image = repository.GetOne(pic => pic.Id == id).Image;
            Response.ContentType = "image/jpeg";
            Response.BinaryWrite(image);
            Response.Flush();

            return View();
        }

        public ActionResult ReceiptPrint(int id)
        {
            var repository = Kernel.Get<IReceiptRepository>();
            var receipt = repository.GetOne(pic => pic.Id == id);
            Response.ContentType = "text/plain";
            Response.Write(receipt.Title);
            Response.Flush();
            Response.End();

            return View();
        }
    }
}
